using GameFramework.Localization;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;

namespace LS.Localization
{
    public class LocalizationSetting : ScriptableObject
    {
        [SerializeField]
        private List<Content> m_Collection = new List<Content>();

        public List<Content> Collection
        {
            get
            {
                return m_Collection;
            }
        }

        public bool HasLanguage(Language language)
        {
            return GetLanguage(language) != null;
        }

        public LanguageSetting GetLanguage(Language language)
        {
            return m_Collection.FirstOrDefault(c => c.Language == language)?.Setting;
        }

        [System.Serializable]
        public class Content
        {
            [SerializeField]
            public Language m_Language;

            [SerializeField]
            private LanguageSetting m_Setting;

            public Language Language
            {
                get
                {
                    return m_Language;
                }
            }

            public LanguageSetting Setting
            {
                get
                {
                    return m_Setting;
                }
            }

            public Content() { }

            public Content(LanguageSetting setting)
            {
                if (setting != null)
                {
                    m_Language = setting.Language;
                    m_Setting = setting;
                }
            }
        }
    }
}
